<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"/>
        <title>Tane - Hide Delegate - Usage</title>
    </head>
    <body>
    	<h1>Hide Delegate - Usage</h1>
    	<p>Given the code at the start of the above example, select the code to be refactored in the Java editor:</p>
    	
    	<div class="code">
Foo foo = new Foo();
&#8230;
foo.<span class="selected">getBar().getBaz().doSomething()</span>;
    	</div>
    	
    	<p>Note that you can select any part of the sequence of invocations. You could, for example, have selected just
    		<span class="code">getBar().getBaz()</span> or <span class="code">getBaz().doSomething()</span>.</p>
    	<p>Now bring up the context sensitive menu and select the 'Hide Delegate...' menu item (note that this menu item is <b>not</b>
    		under the Refactor sub-menu because we <a href="http://dev.eclipse.org/newslists/news.eclipse.tools.jdt/msg22831.html"
    		title="Question on the news.eclipse.tools.jdt newsgroup about adding to the refactoring menu">don't know how</a> to get that
    		to happen). The refactoring wizard that appears
    		will check that appropriate <a href="preconditions.html" title="Hide Delegate Preconditions">preconditions</a> have been met and
    		then ask for some information:</li>
    	<ul>
    		<li>A name for the new method.</li>
    		<li>The scope for replacement. This refactoring will search the selected scope for the same method invocation sequence that was
    			selected and replace it with a call to the new method. This is a powerful way of replacing significant amounts of code with a
    			better alternative, particularly if the code exhibits symptoms of 'procedural' thinking.</li>
    	</ul>
    	<p>After entering the appropriate information, click 'Next'. The refactoring will work out what needs to be done and then show you a
    		preview of the work to be done, as usual. If you are happy with the changes, click 'Finish' and the changes will be applied.</p>
    		
       	<hr/>
    	<div class="attribution">
    		This plugin is provided by <a href="http://www.stateofflow.com" title="State Of Flow homepage">State Of Flow</a>
    	</div>
    </body>
</html>